import os
import pathlib
import secrets
import rsa     ##pip install rsa
import cryptography    ##pip install cryptography
path_now = os.getcwd()
while True:
    print('请选择操作：\n1.生成新rsa密钥对（请确保您当前目录下没有其它密钥对文件，否则这个操作将覆盖它们！）\n2.加密图片（生成rsa密钥对后使用）\n3.解密图片\n4.退出')
    re=input('输入数字序号：')
    if re in ['1','1.']:
        (pubk, prik) = rsa.newkeys(4096)
        with open('public_key.pem','wb') as pubfile:
            pubfile.write(pubk.save_pkcs1())
            print(f'公钥已经保存到{path_now}/public_key.pem')
        with open('private_key.pem','wb') as prifile:
            prifile.write(prik.save_pkcs1())
            print(f'私钥已经保存到{path_now}/private_key.pem，请妥善保存，私钥泄露后其他人可以看见使用公钥加密的信息！')
    elif re in ['2','2.']:
        path = input(f'输入图片路径（当前路径下的路径，请不要在开头添加‘/’）{path_now}:')
        bytes1 = pathlib.Path(path).read_bytes()
        sec = secrets.token_bytes(256)
        